<div id="zone">
    <div class="red">
        [$result.msg]
    </div>
	<div class="show_title">
		<h2>添加/编辑广告位信息</h2>
	</div>
	<div id="sec_module">
	</div>
	<div id="main_module">
		<div id="main_module_content">
		    <form action="/admin/admin_zone/savezone" name="savezone" id="savezone" method="post">
	            <input type="hidden" name="zone[z_id]" value="[$zone.z_id]"/>
	            <input type="hidden" name="zone[z_key]" value="[$zone.z_key]"/>
				<table>
	                <tr>
	                    <td width="200px">
	                        位置名称
	                    </td>
	                    <td>
	                        <input type="text" value="[@htmlspecialchars($zone.z_name)]" name="zone[z_name]"/>
	                    </td>
	                </tr>
					 <tr>
	                    <td width="200px">
	                        所属站点
	                    </td>
	                    <td>
	                        <input type="text" value="[@htmlspecialchars($zone.z_site)]" name="zone[z_site]"/>
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        联系人
	                    </td>
	                    <td>
	                        <input type="text" value="[@htmlspecialchars($zone.z_link_man)]" name="zone[z_link_man]"/>
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        电话
	                    </td>
	                    <td>
	                        <input type="text" value="[@htmlspecialchars($zone.z_link_phone)]" name="zone[z_link_phone]"/>
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        邮件
	                    </td>
	                    <td>
	                        <input type="text" value="[@htmlspecialchars($zone.z_link_email)]" name="zone[z_link_email]"/>
	                    </td>
	                </tr>
	                <!--<tr>
	                    <td>
	                       有效时间
	                    </td>
	                    <td>
	                    	<if $zone.start_time>
	                    		From <input type="" size='10' id="from" value="[@date('Y-m-d',$zone.start_time)]" name="zone[start_time]"/>To <input type="" id="to" value="[@date('Y-m-d',$zone.end_time)]" size=10 name="zone[end_time]"/><span class="red">*</span>
	                    	<else>
	                    		From <input type="" size=10 id="from" value="" name="zone[start_time]"/>To <input type="" id="to" value="" size=10 name="zone[end_time]"/><span class="red">*</span>
	                    	</if>
	                    </td>
	                </tr>-->
	                <tr>
	                    <td>
	                        尺寸
	                    </td>
	                    <td>
	                        宽度：<input type="" size="10" value="[@htmlspecialchars($zone.z_width)]" name="zone[z_width]"/>px 高度：<input size="10" type="" value="[@htmlspecialchars($zone.z_height)]" name="zone[z_height]"/>px
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        样式
	                    </td>
	                    <td>
	                        <textarea class=textarea name="zone[z_style]">[@htmlspecialchars($zone.z_style)]</textarea>
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        排序
	                    </td>
	                    <td>
	                        <input type="" size="10" value="[@htmlspecialchars($zone.sort)]" name="zone[sort]"/>
	                    </td>
	                </tr>
	            </table><input type="submit" class="input" name="submit_btn" value="保存"/>
		    </form>
		</div>
	</div>
	<link type="text/css" rel="stylesheet" href="/html/js/ui/datepicker/style/ui.all.css"></style>
	<script src="/html/js/ui/datepicker/ui.datepicker.js"></script>
    <script>
        $(function(){
            $(":submit").click(function(e){
                var val = $("#media_type").val();
				var mt = $("#media_type option:selected").attr("mt");
                var items = $(".media_item[item=" + val + "]").find(".ads_item_input");
                var arr = [];
				$("[name=mt]").val(mt);
                try {
                    for (var i = 0; i < items.size(); i++) {
                        var $id = $(items[i]).attr("id");
                        var $val= $(items[i]).val();
                        arr.push({"id":$id,"val":$val});
                    }
                    $arrs = $.array2String(arr);
                    $("#zone_banners").val($arrs);
                } 
                catch ($e) {
                }
                
                $.ajaxSubmit($(this).parents('form'), function(data){
                    $.showPageInfo("#page_info", data.info, 500, true);
                });
                return false;
            });
			
            $("#media_type").change(function(){
                var val = $(this).val();
                $(".media_item").hide();
                $(".media_item[item=" + val + "]").show();
                return false;
            });
			$("#media_type").trigger("change");
			
            $(".add_select_item").click(function(){
                var $div = $(".ads_item:first");
                var $sp = $div.clone(true);
                $sp.find(":text").val("").attr("id", "");
                $sp.append("<span class='del_item'>X</span>");
                $(".ads_item:last").after($sp);
                return false;
            });
            $(".del_item").live('click', function(){
                $(this).parents(".ads_item").remove();
            });
            $(".select_ads").bind('click', function(){
                var id = "", name = "";
                var $input = $(this).prev(".ads_item_input");
                Dialog.load('/admin/admin_banner/getbannerlist', {
                    closeOnEscape: true,
                    closeBtn: '.select_banner',
                    afterShow: function(){
                        $(".select_banner").mouseup(function(){
                            id = $(this).attr("id");
                            name = $(this).attr("name");
                            $input.val(name);
                            $input.attr("id", id);
                        });
                    },
                    show: 'dropIn',
                    showTime: 300,
                    hide: 'dropOut',
                    modal: true,
                    center: true,
					cache:false
                });
                return false;
            });
			var dates = $("#from,#to").datepicker({
				dateFormat:"yy-mm-dd",
				changeMonth: true,
				changeYear: true,
				showAnim:'fadeIn',
				onSelect: function( selectedDate ) {
						var option = this.id == 'from' ? "minDate" : "maxDate",
							instance = $( this ).data( "datepicker" );
							date = $.datepicker.parseDate(
								instance.settings.dateFormat ||
								$.datepicker._defaults.dateFormat,
								selectedDate, instance.settings );
						dates.not( this ).datepicker( "option", option, date );
					}
			}); 
            
        })
    </script>
</div>
